package com.yanqu.road.server.cmd.wineshop;

import com.yanqu.road.pb.wineshop.WineShopProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.wineshop.WineShopModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/7/26 18:09
 */
@Cmd(code = GameProtocol.S_WINESHOP_RANDOM_NAME, desc = "酒肆随机名字")
public class WineShopRandomNameCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(WineShopModule.class).randomName();
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            WineShopProto.WineShopRandomNameRespMsg.Builder respMsg = WineShopProto.WineShopRandomNameRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_WINESHOP_RANDOM_NAME, respMsg);
        }
    }
}
